// 文件导出
const downloadFile = (data, name) => {
  if (!data) {
    return
  }
  const url = window.URL.createObjectURL(new Blob([data]))
  const link = document.createElement('a')
  link.style.display = 'none'
  link.href = url
  link.setAttribute('download', `${name}.xls`)

  document.body.appendChild(link)
  link.click()
}
const deepClone = (obj) => {
  if (!obj || typeof obj !== 'object') return
  const res = Array.isArray(obj) ? [] : {}
  for (const k in obj) {
    if (obj[k] && typeof obj[k] === 'object') {
      res[k] = deepClone(obj[k])
    } else {
      res[k] = obj[k]
    }
  }
  return res
}
// // 树形数据
// const arrayToTree = (arr) => {
//   const tree = []
//   arr.forEach(i => {
//     if(tree.indexOf(i.name))
//   })
// }
export default {
  downloadFile,
  deepClone
}
